﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SWRPre
{
    public class ModelLayer
    {
        DiscretizationFile dis;
        float[,] top, bottom, confiningBed;

        public ModelLayer(DiscretizationFile dis, float[,] top, float[,] bottom, float[,] confiningBed)
        {
            // Store references.
            this.top = top;
            this.bottom = bottom;
            this.confiningBed = confiningBed;
        }
        public bool hasConfiningBed()
        {
            return confiningBed != null;
        }
        public float[,] getTop()
        {
            return top;
        }
        public float[,] getBottom()
        {
            return bottom;
        }
        public float[,] getConfiningBed()
        {
            return confiningBed;
        }
        public float getCellThickness(int i, int j)
        {
            return top[i, j] - bottom[i, j];
        }
        public double getTop(Point2D location)
        {
            // Get the x and y cells of the location.
            int x = 0; // dis.getXCellIndex(location.getX());
            int y = 0; // dis.getYCellIndex(location.getY());

            // If either of the indices are invalid, return NaN.
            if (x < 0 || y < 0)
                return Double.NaN;

            // Return the value of the top array at the appropriate cell.
            return top[x, y];
        }
        public float getBottom(Point2D location)
        {
            // Get the x and y cells of the location.
            int x = 0; // dis.getXCellIndex(location.getX());
            int y = 0; // dis.getYCellIndex(location.getY());

            // If either of the indices are invalid, return NaN.
            if (x < 0 || y < 0)
            {
                return float.NaN;
            }

            // Return the value of the bottom array at the appropriate cell.
            return bottom[x, y];
        }
        public float getConfiningBed(Point2D location)
        {
            // If the confining bed is null, return NaN.
            if (confiningBed == null)
                return float.NaN;

            // Get the x and y cells of the location.
            int x = 0; // dis.getXCellIndex(location.getX());
            int y = 0; // dis.getYCellIndex(location.getY());

            // If either of the indices are invalid, return NaN.
            if (x < 0 || y < 0)
            {
                return float.NaN;
            }

            // Return the value of the top array at the appropriate cell.
            return confiningBed[x, y];
        }
    }
}
